package org.traffometer.traffosim;

//import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.ByteArrayOutputStream;
//import java.io.File;
import java.io.PrintStream;

//import org.junit.Ignore;
import org.junit.Test;

/**
 * Provides tests for CommandLineUi class.
 * 
 * @author Nam Nguyen
 */
public class TestCommandLineUi {

  /**
   * Tests constructor.
   */
  @Test
  public void testConstructor () {
    CommandLineUi testUi = null;
    String configFilename = "lib/config/static-sample.cfg";
    ByteArrayOutputStream testOut = new ByteArrayOutputStream();
    //PrintStream saveOut = System.out;
    System.setOut(new PrintStream(testOut));

    try {
      testUi = new CommandLineUi (new String[] {"-list", "-config", configFilename,
          "-server", "1.1.1.1"});
    }
    catch (ConfigException e) {
      fail("Got exception opening config file" + e);
    }
    testUi.start();
    
//    System.setOut(saveOut);
//    assertEquals("expect example output", new Config (new File(configFilename)).toPrettyString(), 
//        testOut.toString());

//    new CommandLineUi (new String[] {"-config", "lib/config/static-sample.cfg", "-server",
//        "1.1.1.1"});
    
//    System.setOut(new PrintStream(testOut));
//    new CommandLineUi (new String[] {"-list", "-server", "1.1.1.1"});
//    System.setOut(saveOut);
//    assertEquals("expect example output", CommandLineUi.missingConfigErrorMsg, 
//        testOut.toString());
//
//    System.setOut(new PrintStream(testOut));
//    new CommandLineUi (new String[] {"-list", "-server", "1.1.1.1"});
//    System.setOut(saveOut);
//    assertEquals("expect example output", CommandLineUi.missingServerErrorMsg, 
//        testOut.toString());
    
//    new CommandLineUi (new String[] {"-list", "-config", "lib/config/static-sample.cfg"});
  } 
}
